/*
 * Copyright 2011 Christoph Ludwig (christoph[at]chludwig.de). All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.chludwig.ehumanities.provenance.persistence;

import java.io.File;
import java.util.UUID;

/**
 * central class of the filesystem based HPT persistence layer.
 */
public class StorageArea {

  private static File staticRoot = null;

  public static void setRoot(File newRoot) {
    staticRoot = newRoot;
  }

  private File root;
  /**
   * The relative name of the folder where containers are zipped.
   */
  public static final String ARCHIVE_FOLDER_NAME = "zip";
  /**
   * The relative name of the folder where containers are stored before they are
   * zipped.
   */
  public static final String STAGING_FOLDER_NAME = "staging";

 
  /**
   * The relative name of the folder where temporary files are stored.
   */
  public static final String TMP_FOLDER_NAME = "tmp";

  
  public StorageArea() {
    root = staticRoot;
  }

  public File getRoot() {
    return root;
  }

  public WorkflowContainerPO getContainerPO(UUID uuid) {
    return new WorkflowContainerPO(this, uuid);
  }

  public ArchivePO getArchivePO(UUID uuid) {
    return new ArchivePO(this, uuid);
  }

  public File getStagingFolder() {
    return new File(getRoot(), STAGING_FOLDER_NAME);
  }

  public File getArchivesFolder() {
    return new File(getRoot(), ARCHIVE_FOLDER_NAME);
  }

  public File getTmpFolder() {
    return new File(getRoot(), TMP_FOLDER_NAME);
  }

 
}
